#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time    : 2022/12/29 9:31
# @Author  : afraidbenq
# @File    : faker_control.py
# @Software: PyCharm
# @Github  : github/afraidbenq
# @Email   : 329189987@qq.com
# @Desc    :
"""
faker封装
随机生成测试数据
"""
import random
from faker import Faker


class GenerateData:

    def __init__(self):
        self.faker = Faker(locale='zh_CN')

    @classmethod
    def randint(cls, min: int = 0, max: int = 5000) -> int:
        """
        :return: 随机生成整数
        """
        _data = random.randint(min, max)
        return _data

    def random_int(self, min: int = 1, max: int = 999) -> int:
        """
        :return: 随机生成整数
        """
        random_num = self.faker.random_int(min=min, max=max)
        return random_num

    def random_name(self) -> str:
        """
        :return: 随机生成姓名
        """
        name = self.faker.name()
        return name

    def random_female_name(self) -> str:
        """
        :return: 随机生成女生姓名
        """
        female_name = self.faker.name_female()
        return female_name

    def random_male_name(self) -> str:
        """
        :return: 随机生成男生姓名
        """
        male_name = self.faker.name_male()
        return male_name

    def random_phone(self) -> int:
        """
        :return: 随机生成手机号码
        """
        phone = self.faker.phone_number()
        return phone

    def random_ssn(self) -> int:
        """
        :return: 随机生成身份证号码
        """
        ssn = self.faker.ssn()
        return ssn

    def random_card_num(self) -> int:
        """
        :return: 随机生成银行卡号码
        """
        card_number = self.faker.credit_card_number()
        return card_number

    def random_address(self) -> str:
        """
        :return: 随机生成带邮政编码的地址
        """
        addr = self.faker.address()
        return addr

    def random_company(self) -> str:
        """
        :return: 随机生成公司名称
        """
        company = self.faker.company()
        return company

    def random_email(self) -> str:
        """
        :return: 随机生成邮箱
        """
        email = self.faker.email()
        return email

    def random_job(self) -> str:
        """
        :return: 随机生成职业/职称
        """
        job = self.faker.job()
        return job

    def random_country(self) -> str:
        """
        :return: 随机生成国家
        """
        country = self.faker.country()
        return country

    def random_province(self) -> str:
        """
        :return: 随机生成省份
        """
        province = self.faker.province()
        return province

    def random_city(self) -> str:
        """
        :return: 随机生成城市
        """
        city = self.faker.city()
        return city

    def random_simple_profile(self) -> dict:
        """
        :return: 随机生成简单个人信息
        """
        simple_profile = self.faker.simple_profile()
        return simple_profile

    def random_profile(self) -> dict:
        """
        :return: 随机生成详细个人信息
        """
        profile = self.faker.profile()
        return profile

    def random_en_str(self) -> str:
        """
        :return: 随机生成英文字符串 20位 不限大小写
        """
        pystr = self.faker.pystr()
        return pystr

    def random_word(self) -> str:
        """
        :return: 随机生成两个字的中文词语
        """
        word = self.faker.word()
        return word

    def random_text(self) -> str:
        """
        :return: 随机生成一段文本
        """
        text = self.faker.text()
        return text

    def random_year(self) -> str:
        """
        :return: 随机生成年份
        """
        year = self.faker.year()
        return year

    def random_month(self) -> str:
        """
        :return: 随机生成月份
        """
        month = self.faker.month()
        return month

    def random_date(self) -> str:
        """
        :return: 随机生成日期 年-月-日 1995-07-04
        """
        date = self.faker.date()
        return date

    def random_date_between(self, start_date="-3y", end_date="-1y") -> str:
        """
        :return: 随机生成自定义时间段内日期 年-月-日 1995-07-04
        """
        date = self.faker.date_between(start_date=start_date, end_date=end_date)
        return str(date)

    def random_future_date(self) -> str:
        """
        :return: 随机生成未来日期 年-月-日 2023-01-02
        """
        date = self.faker.future_date()
        return str(date)

    def random_date_this_year(self) -> str:
        """
        :return: 随机生成本年的日期 年-月-日 2022-07-04
        """
        date = self.faker.date_this_year()
        return str(date)

    def random_date_time(self) -> str:
        """
        :return: 随机生成日期和时间 年-月-日 时:分:秒 1982-01-10 18:56:40
        """
        date_time = self.faker.date_time()
        return str(date_time)

    def random_date_time_between(self, start_date="-3y", end_date="-1y") -> str:
        """
        :return: 随机生成自定义时间段内日期和时间 年-月-日 时:分:秒 1982-01-10 18:56:40
        """
        date_time = self.faker.date_time_between(start_date=start_date, end_date=end_date)
        return str(date_time)

    def random_future_date_time(self) -> str:
        """
        :return: 随机生成未来日期和时间 年-月-日 时:分:秒 2022-12-31 18:15:39
        """
        date_time = self.faker.future_datetime()
        return str(date_time)


if __name__ == '__main__':
    g = GenerateData()
    # a = GenerateData.randint()
    # print(a)
    # b = g.random_phone()
    # b = g.random_address()
    # b = g.random_company()
    # b = g.random_card_num()
    # b = g.random_email()
    # b = g.random_job()
    # b = g.random_city()
    # b = g.random_country()
    # b = g.random_profile()
    # b = g.random_name()
    # b = g.random_en_str()
    # b = g.random_word()
    # b = g.random_text()
    # b = g.random_int()
    # b = g.random_year()
    # b = g.random_month()
    # b = g.random_date()
    # b = g.random_date_this_year()
    # b = g.random_date_time()
    # b = g.random_date_time_between()
    # b = g.random_date_between()
    # b = g.random_future_date()
    b = g.random_future_date_time()
    print(type(b))
    print(b)
